import cheerio from "cheerio";
import got from "got";
import { LiverBaseInfo } from "../declare/liver";
export async function GetUserInfo(id: number): Promise<LiverBaseInfo> {
  const pages = await Promise.all([
     got(`https://m.acfun.cn/upPage/${id}`),
     got(`https://live.acfun.cn/live/${id}`)
  ])
  const page = pages[0]
  const page1 = pages[1]
  const $ = cheerio.load(page.body);
  const $1 = cheerio.load(page1.body);
  const name = $(".name .text-overflow").text();
  const followed = Number($("#follow").attr()["data-followed"]);
  const clubCount = Number(
    $(".fans-view").children("span").text().split("人")[0]
  );
  const avatarUrl = $1('.live-author-avatar-img').attr()['src']
  return { id, name, followed, clubCount ,avatarUrl };
}
